#include "SendControlPointListCmd.h"


SendControlPointListCmd::SendControlPointListCmd(QObject *parent) :
    BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::ZigbeeControlProtocol;
    this->m_functionCode = FunctionCode;
}

Package SendControlPointListCmd::toPackage()
{
    Package package;
    QByteArray body;

    body.append(m_zigbee.mac());
    body.append(m_zigbee.nwk());
    body.append(m_zigbee.pointList().size());
    foreach(const ControlPointStruct &controlPoint,m_zigbee.pointList())
    {
        body.append(controlPoint.address() & 0xFF);
        body.append(controlPoint.address() >> 8);
        body.append(controlPoint.value() & 0xFF);
        body.append(controlPoint.value() >> 8);
    }

    package.setFunction(FunctionCode);
    package.setBody(body);
    return package;
}

void SendControlPointListCmd::unPackage(Package package)
{
    Q_UNUSED(package);
}
ZigbeeStruct SendControlPointListCmd::zigbee() const
{
    return m_zigbee;
}

void SendControlPointListCmd::setZigbee(const ZigbeeStruct &zigbee)
{
    m_zigbee = zigbee;
}
